<?php
/********************************************************************
 *	Author:
 *		Jestery Liu <jestery@gmail.com>
 *		http://www.pte.cn
 *
 *	File:			init.class.php
 *	Create Date:	2006-12-24 22:37:30 CST
 *******************************************************************/
class Init
{
	public function __construct(){}
	
	public function initConfig()
	{
		$config = new Config(PTE::getConfigFile());
		Instances::put($config, 'config');
		return true;
	}

	public function initCharset()
	{
		$config = Instances::get('config');
		if ($config->get('FORCE_CHARSET'))
			ini_set('default_charset', CHARSET);
		return true;
	}

	public function initTimezone()
	{
		$config = Instances::get('config');
		$timezone = $config->get('TIMEZONE');
		date_default_timezone_set($timezone);
		return true;
	}

	public function initGpc()
	{
		if (1==get_magic_quotes_gpc())
		{
			Filter::rStripSlashes($_GET);
			Filter::rStripSlashes($_POST);
			Filter::rStripSlashes($_COOKIE);
		}
		return true;
	}

	public function initDb()
	{
		$config = Instances::get('config');
		$db = new DB($config->get('DB_HOST'), $config->get('DB_USER'), $config->get('DB_PASS'), $config->get('DB_NAME'), $config->get('DB_CHARSET'), $config->get('DB_PORT'), $config->get('DB_SOCKET'));
		Instances::put($db, 'db');
		return true;
	}
}

/* vim: set ts=4 sw=4 ff=unix: */
